# Copyright 2024-2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")

package(
    default_visibility = ["//visibility:public"],
)

cc_library(
    name = "color",
    srcs = ["color.cc"],
    hdrs = ["color.h"],
    deps = [
        "//ink/color",
        "//ink/color:color_space",
        "//ink/storage/proto:color_cc_proto",
        "@com_google_absl//absl/log:absl_check",
        "@com_google_absl//absl/log:absl_log",
    ],
)

cc_test(
    name = "color_test",
    srcs = ["color_test.cc"],
    deps = [
        ":color",
        ":proto_matchers",
        "//ink/color",
        "//ink/color:color_space",
        "//ink/storage/proto:color_cc_proto",
        "@com_google_fuzztest//fuzztest",
        "@com_google_fuzztest//fuzztest:fuzztest_gtest_main",
    ],
)

cc_library(
    name = "stroke_input_batch",
    srcs = ["stroke_input_batch.cc"],
    hdrs = ["stroke_input_batch.h"],
    deps = [
        ":input_batch",
        "//ink/geometry:angle",
        "//ink/geometry:rect",
        "//ink/storage/proto:coded_numeric_run_cc_proto",
        "//ink/storage/proto:stroke_input_batch_cc_proto",
        "//ink/strokes/input:stroke_input",
        "//ink/strokes/input:stroke_input_batch",
        "//ink/types:duration",
        "//ink/types:iterator_range",
        "//ink/types:numbers",
        "//ink/types:physical_distance",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
    ],
)

cc_test(
    name = "stroke_input_batch_test",
    srcs = ["stroke_input_batch_test.cc"],
    deps = [
        ":numeric_run",
        ":stroke_input_batch",
        "//ink/geometry:angle",
        "//ink/storage/proto:stroke_input_batch_cc_proto",
        "//ink/strokes/input:fuzz_domains",
        "//ink/strokes/input:stroke_input",
        "//ink/strokes/input:stroke_input_batch",
        "//ink/strokes/input:type_matchers",
        "//ink/types:duration",
        "//ink/types:iterator_range",
        "//ink/types:physical_distance",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/types:span",
        "@com_google_fuzztest//fuzztest",
        "@com_google_fuzztest//fuzztest:fuzztest_gtest_main",
    ],
)

cc_library(
    name = "input_batch",
    srcs = ["input_batch.cc"],
    hdrs = ["input_batch.h"],
    deps = [
        ":numeric_run",
        "//ink/geometry:point",
        "//ink/storage/proto:stroke_input_batch_cc_proto",
        "//ink/types:duration",
        "//ink/types:iterator_range",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
    ],
)

cc_test(
    name = "input_batch_test",
    srcs = ["input_batch_test.cc"],
    deps = [
        ":input_batch",
        "//ink/geometry:type_matchers",
        "//ink/storage/proto:stroke_input_batch_cc_proto",
        "//ink/types:iterator_range",
        "//ink/types:numbers",
        "//ink/types:type_matchers",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_googletest//:gtest_main",
        "@protobuf",
    ],
)

cc_library(
    name = "mesh",
    srcs = ["mesh.cc"],
    hdrs = ["mesh.h"],
    deps = [
        ":mesh_format",
        ":numeric_run",
        "//ink/geometry:mesh",
        "//ink/geometry:mesh_format",
        "//ink/geometry:mesh_packing_types",
        "//ink/geometry:point",
        "//ink/geometry/internal:mesh_packing",
        "//ink/storage/proto:coded_numeric_run_cc_proto",
        "//ink/storage/proto:mesh_cc_proto",
        "//ink/types:iterator_range",
        "//ink/types:small_array",
        "@com_google_absl//absl/log:absl_check",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/types:span",
    ],
)

cc_test(
    name = "mesh_test",
    srcs = ["mesh_test.cc"],
    deps = [
        ":mesh",
        ":numeric_run",
        "//ink/geometry:fuzz_domains",
        "//ink/geometry:mesh",
        "//ink/geometry:mesh_format",
        "//ink/geometry:point",
        "//ink/geometry:type_matchers",
        "//ink/storage/proto:mesh_cc_proto",
        "//ink/types:iterator_range",
        "@com_google_absl//absl/container:inlined_vector",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:status_matchers",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/types:span",
        "@com_google_fuzztest//fuzztest",
        "@com_google_fuzztest//fuzztest:fuzztest_gtest_main",
        "@protobuf",
    ],
)

cc_library(
    name = "mesh_format",
    srcs = ["mesh_format.cc"],
    hdrs = ["mesh_format.h"],
    deps = [
        "//ink/geometry:mesh_format",
        "//ink/geometry/internal:mesh_constants",
        "//ink/storage/proto:mesh_cc_proto",
        "//ink/types:small_array",
        "@com_google_absl//absl/log:absl_log",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
    ],
)

cc_test(
    name = "mesh_format_test",
    srcs = ["mesh_format_test.cc"],
    deps = [
        ":mesh_format",
        ":proto_matchers",
        "//ink/geometry:fuzz_domains",
        "//ink/geometry:mesh_format",
        "//ink/geometry:type_matchers",
        "//ink/storage/proto:mesh_cc_proto",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_fuzztest//fuzztest",
        "@com_google_fuzztest//fuzztest:fuzztest_gtest_main",
    ],
)

cc_library(
    name = "mesh_vertices",
    srcs = ["mesh_vertices.cc"],
    hdrs = ["mesh_vertices.h"],
    deps = [
        ":numeric_run",
        "//ink/storage/proto:mesh_cc_proto",
        "//ink/strokes/internal:legacy_vertex",
        "//ink/types:iterator_range",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
    ],
)

cc_test(
    name = "mesh_vertices_test",
    srcs = ["mesh_vertices_test.cc"],
    deps = [
        ":mesh_vertices",
        "//ink/geometry:type_matchers",
        "//ink/storage/proto:mesh_cc_proto",
        "//ink/strokes/internal:legacy_vertex",
        "//ink/types:iterator_range",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_googletest//:gtest_main",
        "@protobuf",
    ],
)

cc_library(
    name = "partitioned_mesh",
    srcs = ["partitioned_mesh.cc"],
    hdrs = ["partitioned_mesh.h"],
    deps = [
        ":mesh",
        ":mesh_format",
        ":numeric_run",
        "//ink/geometry:mesh",
        "//ink/geometry:mesh_format",
        "//ink/geometry:mesh_index_types",
        "//ink/geometry:partitioned_mesh",
        "//ink/storage/proto:coded_numeric_run_cc_proto",
        "//ink/storage/proto:mesh_cc_proto",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/types:span",
    ],
)

cc_test(
    name = "partitioned_mesh_test",
    srcs = ["partitioned_mesh_test.cc"],
    deps = [
        ":mesh_format",
        ":numeric_run",
        ":partitioned_mesh",
        "//ink/geometry:mesh",
        "//ink/geometry:mesh_format",
        "//ink/geometry:mesh_index_types",
        "//ink/geometry:partitioned_mesh",
        "//ink/geometry:type_matchers",
        "//ink/storage/proto:mesh_cc_proto",
        "//ink/types:iterator_range",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/types:span",
        "@com_google_fuzztest//fuzztest",
        "@com_google_fuzztest//fuzztest:fuzztest_gtest_main",
        "@protobuf",
    ],
)

cc_library(
    name = "numeric_run",
    srcs = ["numeric_run.cc"],
    hdrs = ["numeric_run.h"],
    deps = [
        "//ink/storage/proto:coded_numeric_run_cc_proto",
        "//ink/types:iterator_range",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
    ],
)

cc_library(
    name = "brush",
    srcs = ["brush.cc"],
    hdrs = ["brush.h"],
    deps = [
        ":color",
        "//ink/brush",
        "//ink/brush:brush_behavior",
        "//ink/brush:brush_coat",
        "//ink/brush:brush_family",
        "//ink/brush:brush_paint",
        "//ink/brush:brush_tip",
        "//ink/brush:color_function",
        "//ink/brush:easing_function",
        "//ink/geometry:angle",
        "//ink/geometry:point",
        "//ink/geometry:vec",
        "//ink/storage/proto:brush_cc_proto",
        "//ink/storage/proto:brush_family_cc_proto",
        "//ink/storage/proto:stroke_input_batch_cc_proto",
        "//ink/types:duration",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/container:inlined_vector",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
        "@com_google_absl//absl/types:span",
    ],
)

cc_test(
    name = "brush_test",
    srcs = ["brush_test.cc"],
    shard_count = 10,
    deps = [
        ":brush",
        ":color",
        ":proto_matchers",
        "//ink/brush",
        "//ink/brush:brush_behavior",
        "//ink/brush:brush_coat",
        "//ink/brush:brush_family",
        "//ink/brush:brush_paint",
        "//ink/brush:brush_tip",
        "//ink/brush:color_function",
        "//ink/brush:easing_function",
        "//ink/brush:fuzz_domains",
        "//ink/brush:type_matchers",
        "//ink/color",
        "//ink/geometry:vec",
        "//ink/storage/proto:brush_cc_proto",
        "//ink/storage/proto:brush_family_cc_proto",
        "//ink/storage/proto:color_cc_proto",
        "//ink/storage/proto:stroke_input_batch_cc_proto",
        "//ink/types:duration",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:status_matchers",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings:string_view",
        "@com_google_absl//absl/time",
        "@com_google_fuzztest//fuzztest",
        "@com_google_fuzztest//fuzztest:fuzztest_gtest_main",
    ],
)

cc_test(
    name = "numeric_run_test",
    srcs = ["numeric_run_test.cc"],
    deps = [
        ":numeric_run",
        "//ink/storage/proto:coded_numeric_run_cc_proto",
        "//ink/types:iterator_range",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_fuzztest//fuzztest",
        "@com_google_fuzztest//fuzztest:fuzztest_gtest_main",
    ],
)

cc_library(
    name = "proto_matchers",
    testonly = 1,
    srcs = ["proto_matchers.cc"],
    hdrs = ["proto_matchers.h"],
    deps = [
        "//:gtest_for_library_testonly",
        "@protobuf",
        "@protobuf//:differencer",
    ],
)
